﻿using StockAnalyzerApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace StockAnalyzerApp.Services.Impl
{
    public class PercentChangeDataService : IPercentChangeDataService
    {
        public List<PercentChangeDataItem> toPercentChangeDataList(List<DataItem> dataItemList)
        {
            List<PercentChangeDataItem> result = new List<PercentChangeDataItem>();
            if (dataItemList.Count <= 1) return result;
            for (int i = 0; i < dataItemList.Count - 1; i++)
            {
                result.Add(new PercentChangeDataItem(dataItemList[i], dataItemList[i + 1]));
            }
            return result;
        }
    }
}